<?php

namespace app\modules\Admin\models;

use Yii;

/**
 * This is the model class for table "detail".
 *
 * @property int $detail_id
 * @property string $detail_title 标题
 * @property int|null $detail_type 描述类型
 * @property string|null $detai_com 描述内容
 * @property int|null $detail_top 置顶
 * @property string|null $detail_time
 * @property int|null $status 1正常  2禁用
 * @property string|null $updated_at
 */
class Detail extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'detail';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['detail_title'], 'required'],
            [['detail_type', 'detail_top', 'status'], 'integer'],
            [['detai_com'], 'string'],
            [['detail_time', 'updated_at'], 'safe'],
            [['detail_title'], 'string', 'max' => 256],
        ];
    }

     // 保存前处理
    public function beforeSave($insert) {//{{{

        if($insert){
            $this->detail_time = date("Y-m-d H:i:s");
            $this->status    = 1;
        }
        return parent::beforeSave($insert);
    }//}}}

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'detail_id' => 'ID',
            'detail_title' => '标题',
            'detail_type' => '类型',
            'detai_com' => '描述内容',
            'detail_top' => '置顶',
            'detail_time' => '发布时间',
            'status' => 'Status',
            'updated_at' => '更新时间',
        ];
    }
}